package leetcode.nnumsum;

import java.util.HashMap;

public class Lc454 {


    public int fourSumCount(int[] nums1, int[] nums2, int[] nums3, int[] nums4) {

        HashMap<Integer, Integer> sum = new HashMap<>();
        for (int i = 0; i < nums1.length; i++) {
            for (int j = 0; j < nums2.length; j++) {
                sum.put(nums1[i] + nums2[j], sum.getOrDefault(nums1[i] + nums2[j], 0) + 1);
            }
        }
        int ans = 0;
        for (int i = 0; i < nums3.length; i++) {
            for (int j = 0; j < nums4.length; j++) {
                ans += sum.getOrDefault(-nums3[i] - nums4[j], 0);
            }
        }
        return ans;
    }




}
